home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / go54.zip / INFO.C < prev    next >
Text File  |  1990-11-06  |  9KB  |  403 lines

  1. /*
  2.   ---------------------------------------------------------------------------
  3.   This program is placed into the public domain.  While it does not have all
  4.   the bells and whistles of other programs like SYSID, it does provide the
  5.   basics.
  6.  
  7.   ACKNOWLEDGEMENTS
  8.  
  9.     a.  Bruce Morgan's EMSFUNC.C functions enlightened me to the Turbo C
  10.         geninterrupt () function as well as the use of _AX, etc in place of
  11.         r.x.ax.  I also used his type definitions.
  12.  
  13.     b.  Info on other portions of the program were obtained from Robert
  14.         Alonso's superb book, "Turbo C DOS UTILITIES."
  15.  
  16.   If you enhance this program (and feel free to do so)
  17.   please let me know, and please, do not name your program INFO.EXE as it
  18.   causes confusion among users.
  19.  
  20.   Most of the functions are self-documenting; however, I have placed comments
  21.   where further explanation is necessary.
  22.   ---------------------------------------------------------------------------
  23. */
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <dir.h>
  28. #include <string.h>
  29. #include <dos.h>
  30. #include <conio.h>
  31. #include <graphics.h>
  32. #include <fcntl.h>
  33.  
  34. #define TRUE        1
  35. #define FALSE        0
  36. #define getEMS()    geninterrupt (0x67);  /* Turbo C's get interrupt func- */
  37.                                           /* tion.  Int 67 is for EMS      */
  38. typedef unsigned char byte;
  39. typedef unsigned int word;
  40.  
  41. char *current_directory (char *path)
  42. {
  43.     strcpy (path, "X:\\");            /* copy X:\\ into path   */
  44.     path[0] = 'A' + getdisk();      /* get current drive     */
  45.     getcurdir (0, path+3);          /* get current directory */
  46.     return (path);
  47. }
  48.  
  49. union REGS r;
  50.  
  51. void main (), memory_check (), dos_version ();
  52. void hard_drive_check (), system_check (), restor_cur ();
  53. void directory_and_environment (), hard_disk_ok ();
  54. void video_check (), ems_memory (), del_cur ();
  55.  
  56. /* *env[] reads the environment string (requires argc and argv */
  57. void main (int argc, char *argv[], char *env[])
  58. {
  59.     clrscr ();
  60.     textbackground (BLUE);
  61.     textcolor (YELLOW);
  62.     cprintf ("Quick System Info, 4 February 1990, BSG Software\n\r");
  63.     textbackground (BLACK);
  64.     dos_version ();
  65.     memory_check ();
  66.     ems_memory ();
  67.     video_check ();
  68.     hard_drive_check ();
  69.     hard_disk_ok ();
  70.     system_check ();
  71.     cprintf ("\n\n\rPress any key to continue");
  72.     del_cur ();
  73.     getche ();
  74.     restor_cur ();
  75.     clrscr ();
  76.     directory_and_environment (env);
  77.     textcolor (WHITE);
  78.     cprintf ("\n\n\rPress any key to continue");
  79.     del_cur ();
  80.     getch ();
  81.     restor_cur ();
  82. }
  83.  
  84.  
  85. mem_stats()
  86. {
  87.     r.h.ah = 0x88;
  88.     return int86 (0x15, &r, &r);
  89. }
  90.  
  91.  
  92. void dos_version (void)
  93. {
  94.     r.h.ah = 0x30;
  95.     r.h.al = 0x00;
  96.     intdos (&r, &r);
  97.  
  98.     textcolor (WHITE);
  99.     cprintf ("\n\rDOS version");
  100.     textcolor (LIGHTGREEN);
  101.     cprintf (" %d.%d", r.h.al, r.h.ah);
  102.     textcolor (WHITE);
  103.     cprintf (" is installed\n\r");
  104. }
  105.  
  106.  
  107. void memory_check (void)
  108. {
  109.     int i, mem_size;
  110.  
  111.     mem_size = biosmemory ();
  112.     i = mem_stats ();
  113.     textcolor (WHITE);
  114.     cprintf ("\n\rMemory is configured as..... ");
  115.     textcolor (YELLOW);
  116.     if (i < 0)
  117.         cprintf ("%dK base, 0K extended", mem_size);
  118.     else cprintf ("%dK base, %dK extended",mem_size,i);
  119. }
  120.  
  121.  
  122. void system_check (void)
  123. {
  124.     int status;
  125.  
  126.     status = biosequip ();        /* determine presense of coprocessor */
  127.     textcolor (WHITE);
  128.     cprintf ("\n\rA math coprocessor is.......");
  129.     textcolor (YELLOW);
  130.     if ((status & 0x02) == 2)
  131.         cprintf (" present");
  132.     else
  133.         cprintf (" not present");
  134.  
  135.     status = biosequip ();
  136.     status &= 0xE000;
  137.     textcolor (WHITE);
  138.     cprintf ("\n\rParallel ports attached.....");
  139.     textcolor (YELLOW);
  140.     switch (status) {
  141.         case      0 : cprintf (" 0");
  142.                       break;
  143.         case  16384 : cprintf (" 1");
  144.                       break;
  145.         case  32768 : cprintf (" 2");
  146.                       break;
  147.         case  49152 : cprintf (" 3");
  148.                       break;
  149.     }
  150.  
  151.     status = biosequip ();
  152.     status &= 0xE00;
  153.     textcolor (WHITE);
  154.     cprintf ("\n\rSerial ports attached.......");
  155.     textcolor (YELLOW);
  156.     switch (status) {
  157.         case  0 : cprintf (" 0");
  158.                   break;
  159.         case 512: cprintf (" 1");
  160.                   break;
  161.         case 1024 : cprintf (" 2");
  162.                   break;
  163.         case 1536 : cprintf (" 3");
  164.                   break;
  165.     }
  166.  
  167.     status = biosequip ();
  168.     textcolor (WHITE);
  169.     cprintf ("\n\rSerial printers attached....");
  170.     textcolor (YELLOW);
  171.     if ((status & 0x2000) == 0)
  172.         cprintf (" 0\n\r");
  173.     else
  174.         cprintf (" 1\n\r");
  175.  
  176.     textcolor (WHITE);
  177.     cprintf ("Game port present...........");
  178.     textcolor (YELLOW);
  179.     if ((status & 0x1000) == 0)
  180.         cprintf (" No");
  181.     else
  182.         cprintf (" Yes");
  183.  
  184.     textcolor (WHITE);
  185. }
  186.  
  187. void directory_and_environment (env)
  188. char *env[];
  189. {
  190.     int i;
  191.     char curdir[MAXPATH];
  192.  
  193.     textcolor (WHITE);
  194.     current_directory (curdir);
  195.     cprintf ("\n\rThe current directory is.... ");
  196.     textcolor (YELLOW);
  197.     cprintf ("%s", curdir);
  198.  
  199.     textcolor (WHITE);
  200.     cprintf ("\n\n\rThe environment string(s) are: \n\n\r");
  201.  
  202.     textcolor (YELLOW);
  203.     for (i=0; env[i] != NULL; i++)
  204.         cprintf ("   %s\n\r", env[i]);
  205. }
  206.  
  207.  
  208.  
  209. void hard_drive_check (void)
  210. {
  211.     int i, value;
  212.     char c[2], type[25];
  213.  
  214.     textcolor (WHITE);
  215.     cprintf ("\n\rExistent floppy drives...... ");
  216.     for (i=0; i<7; i++) {
  217.         r.h.ah = 0x08;
  218.         r.h.dl = i;
  219.         int86 (0x13, &r, &r);
  220.  
  221.         switch (i) {
  222.             case 0 : strcpy (c,"A");
  223.                     break;
  224.             case 1 : strcpy (c,"B");
  225.                     break;
  226.             case 2 : strcpy (c,"C");
  227.                     break;
  228.             case 3 : strcpy (c,"D");
  229.                     break;
  230.             case 4 : strcpy (c,"E");
  231.                     break;
  232.             case 5 : strcpy (c,"F");
  233.                     break;
  234.             case 6 : strcpy (c,"G");
  235.                     break;
  236.             case 7 : strcpy (c,"H");
  237.                     break;
  238.             case 8 : strcpy (c,"I");
  239.                     break;
  240.         }
  241.  
  242.         switch (r.h.bl) {
  243.             case 1 : strcpy (type, "360 KB, 40 track, 5.25\"");
  244.                     break;
  245.             case 2 : strcpy (type, "1.2 MB, 80 track, 5.25\"");
  246.                     break;
  247.             case 3 : strcpy (type, "720 KB, 80 track, 3.50\"");
  248.                     break;
  249.             case 4 : strcpy (type, "1.44 MB, 80 track, 3.50\"");
  250.                     break;
  251.         }
  252.  
  253.         if (r.h.bl != 0) {
  254.             textcolor (YELLOW);
  255.             cprintf ("%s is a %s drive\n\r", c, type);
  256.             cprintf ("                             ");
  257.  
  258.         }
  259.     }
  260.  
  261.     textcolor (WHITE);
  262.     cprintf ("\rLogical hard drives present: ");
  263.     textcolor (YELLOW);
  264.  
  265.     _AH = 0x0E;                /* calls DOS's interrupt 21, function 0EH - */
  266.     _DL = 8;                /*   select disk & returns # logical drives */
  267.     geninterrupt (0x21);
  268.  
  269.     value = _AL;
  270.     for (i=_AL; i>0; --i) {
  271.         _AH = 0x36;
  272.         _DL = value;
  273.         geninterrupt (0x21);
  274.         if (_AX != 0xffff || _BX < 2000)
  275.             break;
  276.         else value--;
  277.     }
  278.     cprintf ("%d ", value);
  279. }
  280.  
  281. void hard_disk_ok ()
  282. {
  283.     int i, number = 0;
  284.  
  285.     textcolor (WHITE);
  286.     cprintf ("\n\rNumber physical hard drives: ");
  287.     for (i=0; i<27; i++) {
  288.         r.h.ah = 0x10;
  289.         r.h.dl = 0x80+i;
  290.         int86 (0x13, &r, &r);
  291.  
  292.         if (r.h.ah == 0) {
  293.             number += 1;
  294.             textcolor (YELLOW);
  295.             cprintf ("%d ", number);
  296.         }
  297.     }
  298.  
  299. }
  300.  
  301.  
  302. void video_check ()
  303. {
  304.     int graphdriver = DETECT;            /* automatically determine driver*/
  305.     int graphmode;
  306.  
  307.     /* call detectgraph to determine hardware */
  308.     detectgraph (&graphdriver, &graphmode);
  309.  
  310.     if (graphdriver < 0) {
  311.         cprintf ("No graphics hardware available!\n\r");
  312.         exit (1);
  313.     }
  314.  
  315.     /* report detected hardware */
  316.     textcolor (WHITE);
  317.     cprintf ("\n\rType graphics adaptor....... ");
  318.     textcolor (YELLOW);
  319.     switch (graphdriver) {
  320.         case CGA     : cprintf ("Color Graphics Adapter (CGA)");
  321.                        break;
  322.         case MCGA    : cprintf ("Multicolor Graphics Array (MCGA)");
  323.                        break;
  324.         case EGA     :
  325.         case EGA64   :
  326.         case EGAMONO : cprintf ("Enhanced Graphics Adapter (EGA)");
  327.                        break;
  328.         case HERCMONO: cprintf ("Hercules Color Card");
  329.                        break;
  330.         case ATT400  : cprintf ("AT&T 640x400 Card");
  331.                        break;
  332.         case PC3270  : cprintf ("IBM PC 3270");
  333.                        break;
  334.         case VGA     : cprintf ("Video Graphics Array (VGA)");
  335.                        break;
  336.     }
  337. }
  338.  
  339.  
  340. void ems_memory ()
  341. {
  342.     word totalMem, freeMem;
  343.     char *ptr;
  344.  
  345.     ptr = DetectEMM ();
  346.  
  347.     if (ptr != FALSE) {
  348.         _AH = 0x42;     /* get number of ems pages */
  349.         getEMS();
  350.  
  351.         totalMem = _DX;
  352.         freeMem  = _BX;
  353.  
  354.         textcolor (WHITE);
  355.         if (_AH == 0) {
  356.             cprintf ("\n\rTotal expanded memory.......");
  357.             text